<?php
//	file:  AllobdModel.class.php
//	time:  Dec 30, 2015 2:58:38 PM

namespace Have\Model;
use Think\Model;
class AllobdModel extends Model{
    
    public function getLastlocate($obdid='') {
        if ($obdid == '') {
            $map['type'] = 1;
            $locate = $this->where($map)->field('obdid,lastlocate')->select();
        }else{
            $map['obdid'] = $obdid;
            $locate = $this->where($map)->field('obdid,lastlocate')->select();
        }
        foreach ($locate as $key => $value) {
             $locate[$key]['time'] = substr($value['lastlocate'], 0, stripos($value['lastlocate'], '('));
             $locate[$key]['lng'] = substr($value['lastlocate'], stripos($value['lastlocate'], '(')+1, stripos($value['lastlocate'], ',')-stripos($value['lastlocate'], '(')-1);
             $locate[$key]['lat'] = substr($value['lastlocate'], stripos($value['lastlocate'], ',')+1, stripos($value['lastlocate'], ')')-stripos($value['lastlocate'], ',')-1);
        }
        return $locate;
    }
    
//     public function offline() {
//         $map['type'] = 1;
//         $map['stoptime'] = array('notlike', date('Y-m-d').'%');
//         $off = $this->where($map)->field('obdid,stoptime,UNIX_TIMESTAMP(stoptime)')->select();
//         return $off;
//     }
}
	
	
?>